#!usr/bin/node

const mysql = require('mysql2/promise');

async function main() {
  // open connection
  
  const con = await mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'ddd',
    database:'demo'
  });

  // query

  const pageSize = 2,
        offset = (Number(process.argv[2])-1)*2,
        sql = 'select * from areas;'
        //sql = `select * from areas order by id limit ${offset},${pageSize};`;
        //sql = 'delete from areas where id = 7;';    
        //sql = "insert into areas(area_name) values('非洲');";
        //sql = 'update areas set area_name = "澳洲" where area_name = "非洲"';

  const [rows] = await con.query(sql);
  console.table(rows);

  // close connection
  
  con.end();
}

main();
